package com.qhg.saas_server.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qhg.saas_server.mapper.DepartmentMapper;
import com.qhg.saas_server.pojo.Department;
import com.qhg.saas_server.pojo.dto.DepartmentDto;
import com.qhg.saas_server.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepartmentServiceImpl implements DepartmentService {

    @Autowired
    DepartmentMapper departmentMapper;

    @Override
    public PageInfo SelectAllDepartment(Integer pageNum,Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<DepartmentDto> departments = departmentMapper.SelectAllDepartment();
        PageInfo<Department> pageInfo = new PageInfo(departments);
        return pageInfo;
    }

    @Override
    public Department SelectDyId(Integer departId) {
        return departmentMapper.SelectDyId(departId);
    }

    @Override
    public void InsertDepartment(Department department) {
        departmentMapper.InsertDepartment(department);
    }

    @Override
    public void UpdateDepartmentStatus(Integer departStatus, Integer departId) {
        departmentMapper.UpdateDepartmentStatus(departStatus,departId);
    }

    @Override
    public void UpdataDepartmentById(Department department) {
        departmentMapper.UpdataDepartmentById(department);
    }

    @Override
    public void DeleteDepartmentById(Integer departId) {
        departmentMapper.DeleteDepartmentById(departId);
    }
}
